## title:   Narcissism in Political Participation
## authors: Z. Fazekas & P.K. Hatemi
## goal:    helper functions for analysis and plotting
##          to be loaded in scripts for preparation and analysis
## ----
## 1. mean centering and division by two standard deviation
##    see Gelman and Hill (2007) for underlying benefits
two_sd <- function(x){
  (x - mean(x, na.rm = TRUE))/(2*sd(x, na.rm = TRUE))
}

## 2. standard error of the mean
se.mean <- function(x) {
  sqrt(var(x, na.rm = TRUE)/length(x))
  }